package cn.thoughtworks.school.feign;

import cn.thoughtworks.school.entities.UserRole;
import cn.thoughtworks.school.entities.commands.CreateUserOrganization;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


@FeignClient(name = "${feign.userCenter.name}",
  url = "${feign.userCenter.url}")
@Service
public interface UserCenterFeign {

  @GetMapping("/api/users/{userId}")
  Map getUserById(@PathVariable("userId") Long userId);

  @GetMapping("/api/users")
  List<Map> getUserByUserNameOrEmail(@RequestParam("nameOrEmail") String userNameOrEmail);

  @GetMapping("/api/users/ids/{ids}")
  List<Map> getUsersByIds(@PathVariable("ids") String ids);


  @GetMapping("api/organizations/{organizationId}/users/ids/{ids}")
  List<UserRole> getUsersByOrganizationIdAndIds(@PathVariable("organizationId") Long organizationId,
                                                @PathVariable("ids") String ids);

  @GetMapping("api/organizations/{organizationId}/administrators")
  List<UserRole> getAdminsRoleByOrganizationId(@PathVariable("organizationId") Long organizationId);

  @PutMapping("api/users/organizations")
  void updateUserCurrentOrganizationId(@RequestBody CreateUserOrganization createUserOrganization);
}
